<?php
class language extends database{
// add ------
	public function Add($name, $image, $status){				
		if(!$this->isText($name)){
			return 3;
		}else if(!$this->isText($image)){
			return 4;
		}else if(!$this->isInt($status)){
			return 5;
		}else{			
			$sql="insert into language(name, image, status) values('".$name."', '".$image."', ".$status.")";		
			if($result=$this->query($sql)){
				return 1;
			}else{
				return 0;
			}
			return -1;
		}
	}
// edit ------
	public function Edit($id, $name, $image, $status){				
		if(!$this->isInt($id)){
			return 2;
		}else if(!$this->isText($name)){
			return 3;
		}else if(!$this->isText($image)){
			return 4;
		}else if(!$this->isInt($status)){
			return 5;
		}else{			
			$sql="update language set name='".$name."', image='".$image."', status=".$status." where id=".$id."";		
			if($result=$this->query($sql)){
				return 1;
			}else{
				return 0;
			}
			return -1;
		}
	}
// get all
	public function GetByAll($status=10){	
		if(!$this->isInt($status)){
			return 2;
		}else{	
			if($status==10){
				$status	= "status<>2";	
			}else{
				$status	= " status=".$status;	
			}
			$sql="select id, name, image, status from language where ".$status."";
			if($result=$this->query($sql)){
				if($this->CountRow($result)>0){
					while(($a=$this->fetch($result))!=NULL){
						$ds_sp[]=$this->unvalid($a); 
					}
					return $ds_sp;		
				}else{
					return 1;
				}
			}
		}
		return 0;
	}
}
?>